package com.wanmait.happyheating.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.happyheating.pojo.Config;
import com.wanmait.happyheating.pojo.HeatingNumber;
import com.wanmait.happyheating.pojo.WorkersLog;
import com.wanmait.happyheating.mapper.WorkersLogMapper;
import com.wanmait.happyheating.service.WorkersLogService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 员工操作日志 服务实现类
 * </p>
 *
 * @author yuQianTao
 * @since 2021-05-13
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class WorkersLogServiceImpl extends ServiceImpl<WorkersLogMapper, WorkersLog> implements WorkersLogService {
    @Resource
    private WorkersLogMapper workersLogMapper;

    /**
     * 陈宗  2021-06-20
     * 业务逻辑层的维修人员操作日志查询并且分页的方法
     *
     * @param pageNum
     * @param
     * @return
     */
    /*@Override
    public PageInfo<WorkersLog> findPage(int pageNum, WorkersLog workersLog) {
        //设置分页的当前页和每页条数
        PageHelper.startPage(pageNum,2);
        List<WorkersLog> workersLogs=workersLogMapper.selectList(null);
        //实例化pageInfo
        PageInfo<WorkersLog> pageInfo=new PageInfo<>(workersLogs,5);
        return pageInfo;
    }*/
    @Override
    public PageInfo<WorkersLog> findPage(int pageNum, WorkersLog workersLog) {
        //实例化条件封装器
        LambdaQueryWrapper<WorkersLog> logLambdaQueryWrapper=new LambdaQueryWrapper<>();
        //判断维修人员的添加时间
        logLambdaQueryWrapper.eq(WorkersLog::getInputTime,workersLog.getInputTime());
        //设置分页的当前页和每页条数
        PageHelper.startPage(pageNum,2);
        //调用数据访问层根据添加时间查询维修员工日志的方法
        List<WorkersLog> workersLogs=workersLogMapper.selectList(logLambdaQueryWrapper);
        //实例化pageInfo
        PageInfo<WorkersLog> pageInfo=new PageInfo<>(workersLogs,5);
        return pageInfo;
    }


}
